﻿@{
    ViewBag.Title = "品名管理";
    Layout = "~/Views/Shared/_LayoutList.cshtml";
}
@(Html.nbGridFor<Material>(s =>
{
    s.Action(@Url.Action("List"));
    s.Columns(c =>
    {
        c.Bind(m => m.Id).IsKey();
        c.Bind(m => m.Code).Width(60).AsQuery().AsSearch();
        c.Bind(m => m.Name).Width(100).AsQuery().AsSearch().Align(GridAlign.Left);
        //c.BindEnum(m => m.BigClass, "BigClass").Width(60);
        //c.BindEnum(m => m.Category, "MaterialCategory").AsSearch();
        //c.BindEnum(m => m.Type, "MaterialType").AsSearch();
        //c.BindEnum(m => m.Specification, "MaterialSpec");
        c.BindEnum(m => m.Unit, "MaterialUnit");
        c.Bind(m => m.CurrentPrice).Width(50).Align(GridAlign.Right);
        c.Bind(m => m.SafeStorage).Width(50).Align(GridAlign.Right);
        c.BindEnum(m => m.NeedProcess, "IsProcess").Width(40).AsSearch();
        c.Bind(m => m.ProcessRate).Width(40).Align(GridAlign.Right).Process("FormatProcessRate");
        c.Bind(m => m.RawMaterialName).Width(100).AsQuery().AsSearch().Align(GridAlign.Left);
        c.Bind(m => m.UpdateUser).Width(60);
        c.BindDateTime(m => m.UpdateDate).AsSearch();
        c.BindTemplate()
            .Template(Url.GridRowEditLink("编辑品名"))
            .Template(Url.GridRowDeleteLink("Name"));
    });
    s.Buttons(b =>
    {
        b.BindAddButton("新建品名");
        b.BindDeleteButton();
        b.Bind(GridButtonType.Import, "导入品名").Action(Url.Action("Import", new { excelKey = "Material" }));
    });
}))
<script type="text/javascript">
    function FormatProcessRate(value, id, row) {
        if (value != '') {
            return value * 100 + "%";
        }
        return value;
    }
</script>
